{# **
 * Copyright since 2007 PrestaShop SA and Contributors
 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.md.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/OSL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to https://devdocs.prestashop.com/ for more information.
 *
 * @author    PrestaShop SA and Contributors <contact@prestashop.com>
 * @copyright Since 2007 PrestaShop SA and Contributors
 * @license   https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
 * #}

{# The first shop is always displayed entirely and in bold #}
{% set shopsIds = record[column.options.ids_field] %}
{% set shops = record[column.options.field] %}
{% set productId = record[column.options.product_id_field] %}
{% set allShops = shops|join(', ') %}

{% set routeParams = {productId: productId} %}
{% if column.options.shop_group_id is not null %}
  {% set routeParams = routeParams|merge({shopGroupId: column.options.shop_group_id}) %}
{% endif %}

<span class="product-shop-list" title="{{ allShops }}" data-shop-ids="{{ shopsIds|join(',') }}">
  <div class="product-shop-list-names">
    {% set firstShop = shops[0] %}
    <strong>{{ firstShop }}</strong>
    {%- if shops|length > 1 -%}
      ,
      {% set otherShops = shops|slice(1, shops|length)|join(', ') %}
      {# if max_displayed_characters is set and is lower that the whole text length the rest of the shops are truncated #}
      {% if column.options.max_displayed_characters > 0 and allShops|length > column.options.max_displayed_characters %}
        {{ otherShops|slice(0, column.options.max_displayed_characters - firstShop|length) }}&mldr;
      {% else %}
        {{ otherShops }}
      {% endif %}
    {%- endif -%}
  </div>
  {%- if shops|length > 1 -%}
    <div
      class="product-shop-details-toggle"
      data-product-id="{{ productId }}"
      data-shop-previews-url="{{ path('admin_products_grid_shop_previews', routeParams) }}"
    >
    </div>
  {% endif %}
</span>
